﻿using System;
using UnityEngine;

public static partial class Extensions
{
    /// <summary>
    /// 字符串判空
    /// </summary>
    public static bool IsEmpty(this string content)
    {
        return string.IsNullOrEmpty(content);
    }

    /// <summary>
    /// 移除字符串
    /// </summary>
    public static string Remove(this string content, string textToRemove)
    {
        return content.Replace(textToRemove, "");
    }

    /// <summary>
    /// 字符串解析为枚举
    /// </summary>
    public static T Parse<T>(this string content) where T : Enum
    {
        return (T)Enum.Parse(typeof(T), content);
    }

    /// <summary>
    /// 为字符串添加html颜色富文本
    /// </summary>
    public static string RichColor(this string content, Color color)
    {
        return $"<color=#{color.ToRGBString()}>{content}</color>";
    }

    /// <summary>
    /// 为字符串添加html大小富文本
    /// </summary>
    public static string RichSize(this string content, int size)
    {
        return $"<size={size}>{content}</size>";
    }
}